package cat.sun.graphics;

import cat.sun.R;
import cat.sun.dialogs.WinDialog;
import cat.sun.stats.Stats;
import cat.sun.stats.StatsValues;
import android.app.Activity;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

public class DialogsViewer 
{
	public static void showWinDialog(FragmentActivity activity, Stats stats, long time)
	{
		if (stats.IsHeInTop(stats.GetBestScores(), time))
		{
			WinDialog winDialog = WinDialog.newInstance(time);
			winDialog.show(activity.getSupportFragmentManager(), "win_dialog");
		}
		else
		{
			if (stats.getType().equals(StatsValues.CUSTOM_KEY) || stats.getType().equals(StatsValues.RANDOM_KEY))
			{
				View layout = activity.getLayoutInflater().inflate(R.layout.toast_about, null);
				TextView textView = (TextView) layout.findViewById(R.id.toast_message);
				textView.setText(activity.getResources().getString(R.string.WinOnlyToastRandom));
				Toast toast = new Toast(activity);
				toast.setDuration(Toast.LENGTH_LONG);
				toast.setView(layout);
				toast.show();
				return;
			}
			View layout = activity.getLayoutInflater().inflate(R.layout.toast_about, null);
			TextView textView = (TextView) layout.findViewById(R.id.toast_message);
			textView.setText(activity.getResources().getString(R.string.WinOnlyToast));
			Toast toast = new Toast(activity);
			toast.setDuration(Toast.LENGTH_LONG);
			toast.setView(layout);
			toast.show();
		}
	}
	
	public static void showLoseToast(Activity activity)
	{
		View layout = activity.getLayoutInflater().inflate(R.layout.toast_about, null);
		TextView textView = (TextView) layout.findViewById(R.id.toast_message);
		textView.setText(activity.getResources().getString(R.string.loseToast));
		Toast toast = new Toast(activity);
		toast.setDuration(Toast.LENGTH_LONG);
		toast.setView(layout);
		toast.show();
	}
}
